import React from 'react';
import {injectIntl} from 'react-intl';
import Grid from '../../components/table/grid';
import {Row, Button, Form, Icon} from 'antd';

const FormItem = Form.Item;
const createForm = Form.create;
class elePriceInfo extends React.Component {
    constructor() {
        super();
        this.state = {
            refresh:0,
            params:{},
            publicPrices: [],
            privatePrices: []
        }
        this.columns=[
            {
                title: '13',
                dataIndex: 'account',
            },
            {}
        ]
    }

    render(){

        const formItems = keys.map((k, index) => {
            return (
                <FormItem
                    required={false}
                    key={k.uuidKeys}
                >
                    <Row gutter={16}>
                    <Col span={4}>
                            <FormItem
                            >
                                {getFieldDecorator(`range[${index}]`,{
                                    initialValue:k.range
                                })(
                                <Select placeholder={'计费区间'} allowClear={true} optionLabelProp="children">
                                    <Option value={1}>峰时</Option>
                                    <Option value={2}>尖时</Option>
                                    <Option value={3}>谷时</Option>
                                    <Option value={4}>平时</Option>
                                </Select>
                                )}
                            </FormItem>
                        </Col>
                        <Col span={6}>
                            {!k.startTime ?
                                <FormItem>
                                    {getFieldDecorator(`startTime[${index}]`,
                                        {
                                            rules: [{type: 'object', required: true, message: common.PleaseSelectStartTime}],
                                        }
                                    )(
                                        <TimePicker placeholder={common.startTime} format={format}/>
                                    )}
                                </FormItem>
                                :
                                <FormItem>
                                    {getFieldDecorator(`startTime[${index}]`,
                                        {
                                            rules: [{type: 'object', required: true, message: common.PleaseSelectStartTime}],
                                            initialValue: moment(k.startTime, 'HH:mm')
                                        }
                                    )(
                                        <TimePicker disabled={index === 0} format={format}/>
                                    )}
                                </FormItem>
                            }

                        </Col>
                        <Col span={6}>
                            <FormItem
                                {...formItemLayout}
                                label={common.energyChargeUnit}
                            >
                                {getFieldDecorator(`electricityPrice[${index}]`, {
                                    rules: [
                                        {required: true, message: common.PleaseInputElectricityBill,},
                                        {validator: this.maxNumber,}
                                    ],
                                    initialValue: k.electricityPrice

                                })(
                                    <Input/>
                                )}
                            </FormItem>
                        </Col>
                        <Col span={6}>
                            <FormItem
                                {...formItemLayout}
                                label={common.serviceChargeUnit}
                            >
                                {getFieldDecorator(`servicePrice[${index}]`, {
                                    rules: [
                                        {required: true, message: common.PleaseEnterServiceCharge,},
                                        {validator: this.maxNumber,}
                                    ],
                                    initialValue: k.servicePrice
                                })(
                                    <Input/>
                                )}
                            </FormItem>
                        </Col>
                        <Col span={2}>
                            {index !== 0 && keys.length > 1 ? (
                                <Icon
                                    className="dynamic-delete-button"
                                    type="minus-circle-o"
                                    disabled={keys.length === 1}
                                    onClick={() => this.remove(k)}
                                />
                            ) : null}
                        </Col>
                    </Row>
                </FormItem>
            );
        });
        return (
            // <div>/api/stubGroup/feeTemplate/list</div>
            <div>
                <Row type="flex" justify="end">
                    <Button type={'primary'}>新增</Button>
                </Row>
                <Grid style={{marginTop:20}} refresh={this.state.refresh} columns={this.columns} params={this.state.params} url={'/api/stubGroup/feeTemplate/list'}/>
            </div>
        )
    }
}

elePriceInfo=createForm()(elePriceInfo);
export default injectIntl(elePriceInfo);
